package com.hankol.winecellar.adapter

import android.widget.TextView
import com.baselibrary.extension.buildSpannableString
import com.baselibrary.extension.checkValue
import com.baselibrary.extension.load
import com.baselibrary.extension.setMallPriceTTF
import com.baselibrary.utils.AmountUtil
import com.baselibrary.view.RoundCornerImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.hankol.winecellar.R
import com.hankol.winecellar.bean.GoodsManagerListBean

/* 售卖中
已下架
 商品列表
* */
class GoodsManagerAdapter : BaseQuickAdapter<GoodsManagerListBean, BaseViewHolder>(R.layout.item_goods_manager) {

    override fun convert(helper: BaseViewHolder, item: GoodsManagerListBean) {
        helper.apply {
            item.let {
                getView<RoundCornerImageView>(R.id.round_order_cover).load(mContext, it.icon.checkValue())
                setText(R.id.tv_order_title, it.name.checkValue())
                setText(R.id.tv_goods_no, "商品编号：${it.spuId}")
                val tvPrice = getView<TextView>(R.id.tv_price)
                tvPrice.text = "${AmountUtil.changeF2YKeepTwo("${it.showPrice}")}"
//                tvPrice.setMallPriceTTF(mContext)
                getView<TextView>(R.id.tv_unit).setMallPriceTTF(mContext)
                val tvStock = getView<TextView>(R.id.tv_stock)
                tvStock.buildSpannableString {
                    addText("库存：") {
                        setColor("#333333")
                    }
                    addText("${it.stock}") {
                        setColor("#999999")
                    }
                }
                addOnClickListener(R.id.tv_sort)
            }
        }
    }
}